import axios from "@/pages/p-rs/services/request";
import urls from './config';
import { Parameters, DTO } from './type';

// 省钱卡列表
export function getEconomizeCardList(
  params: Parameters.EconomizeCardCommand
) {
  return axios.post<CNPC.Res.page<DTO.EconomizeCardList>>(urls.economizeCard, params)
}

// 省钱卡申请开票列表/关联记录信息
export function getSaveMoneyList(
  params: Parameters.economizeANDcoupons
) {
  return axios.post<CNPC.Res.page<DTO.SaveMoneyInvoiceList>>(urls.saveMoneyInfo, params)
}

// 加油券申请开票列表/关联记录信息
export function getCouponsInvoiceList(
  params: Parameters.economizeANDcoupons
) {
  return axios.post<CNPC.Res.page<DTO.CouponsInvoiceList>>(urls.couponsInvoice, params)
}

// 开票记录
export function getInvoiceList(params: Parameters.Pagination) {
  return axios.post<CNPC.Res.page<DTO.InvoiceList>>(urls.invoiceList, params)
}

// 开票详情信息
export function getInvoiceInfo(
  id: number | string
) {
  return axios.post<CNPC.Res.data<DTO.InvoiceInfo>>(urls.invoiceInfo, { id })
}

// 申请开票
export function addInvoiceInfo(
  params: Parameters.AddInvoiceCommand
) {
  return axios.post<CNPC.Res.data<DTO.InvoiceInfo>>(urls.addInvoice, params)
}

// 重新获取电子发票
export function reloadInvoiceEmial(
  contactsEmail: string,
  id: string
) {
  return axios.post<CNPC.Res.data<null>>(urls.reloadInvoice, { contactsEmail, id })
}

// 省钱卡/加油券id列表
export function getinvoiceIDs(
  couponsType: number
) {
  return axios.post<CNPC.Res.data<any>>(urls.invoiceIds, { couponsType })
}

// 查看发票图片
export function getInvoiceImgData(
  params: Parameters.invoiceImgCommand
) {
  return axios.post<CNPC.Res.data<any>>(urls.invoiceImg, params)
}

// 判断开发票入口是否开启
export function getInvoiceExistsStatus() {
  return axios.post<CNPC.Res.data<any>>(urls.invoiceExistsStatus)
}

